<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

require_once('phpmailer/class.phpmailer.php');

class CI_Phpmailer extends PHPMailer {

    function __construct($exceptions = false) {
        parent::__construct($exceptions);
    }
    
    function init_mail(){
        // set CharSet is utf-8
        $this->CharSet = 'utf-8';
        // telling the class to use SMTP
        $this->IsSMTP();
        // Sets SMTP class debugging on or off
        $this->SMTPDebug = 1;
        // 1 = errors and messages
        // 2 = messages only
        // enable SMTP authentication
        $this->SMTPAuth = TRUE;
        // sets the prefix to the servier
        $this->SMTPSecure = 'ssl';
        // sets GMAIL as the SMTP server
        $this->Host = 'ns2.trangwebvang.net';
        // set the SMTP port for the GMAIL server
        $this->Port = 456;
        // GMAIL username
        $this->Username = "noreply@dealgiadung.com";
        // GMAIL password
        $this->Password = 'b0c057f0a715e648ac5dba9acf9c0ea6@THAILONG';
        $this->SetFrom("noreply@dealgiadung.com", 'Website Support');
        $this->AddReplyTo("noreply@dealgiadung.com", 'Website Support');
    }

    function send_mail($subject, $message, $priority = 3) {
        $this->init_mail();
        $email_to = "khuongxuantruong@gmail.com";
        $this->Priority = $priority;
        $this->Subject = $subject;
        $this->MsgHTML($message);
        //$this->AddAddress($recipient);
        $this->AddAddress($email_to);
        return $this->Send();
    }
}